package com.example.grpcserver.config;

import io.grpc.health.v1.HealthCheckResponse;
import io.grpc.services.HealthStatusManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * gRPC 健康检查配置
 */
@Configuration
public class GrpcHealthConfig {

    /**
     * 注册 gRPC 健康检查服务
     */
    @Bean
    public HealthStatusManager healthStatusManager() {
        HealthStatusManager healthStatusManager = new HealthStatusManager();
        
        // 设置服务状态为 SERVING
        healthStatusManager.setStatus("", HealthCheckResponse.ServingStatus.SERVING);
        healthStatusManager.setStatus("user.UserService", HealthCheckResponse.ServingStatus.SERVING);
        
        return healthStatusManager;
    }
} 